import { constantRoutes, asyncRoutes } from '@/router/index.js'
const state = {
  routes: constantRoutes
}
const mutations = {
  setRoutes(state, filterRoutes) {
    state.routes = [...constantRoutes, ...filterRoutes]
  }
}
const actions = {
  filterRoutes(context, menus) {
    const filterRoutes = asyncRoutes.filter(t => menus.includes(t.name))
    // const filterRoutes = asyncRoutes
    context.commit('setRoutes', filterRoutes)
    return filterRoutes
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
